/**
 * 屏幕管理
 */
class ScreenControl extends egret.DisplayObjectContainer {
    /** 加载地图 */
    private mapItem: MapItem = new MapItem();
    /** 加载按钮 */
    private btnItem: DrawBtn = new DrawBtn();
    /** 加载更多按钮 */
    private moreBtn: Appointment = new Appointment();

    /** 开场动画 */
    private open = new openAnimation();

    public constructor() {
        super();
        this.once(egret.Event.ADDED_TO_STAGE, this.init, this);
    }

    private init() {

        this.addChild(this.open);
        this.open.addEventListener("over", () => {
            this.addChild(this.mapItem);
            this.mapItem.addChild(this.btnItem);
            this.addChild(this.moreBtn);

            this.tip();
        }, this);
    }

    /** 提示 */
    private container = new egret.Sprite();
    private timer = new egret.Timer(1000 * 3, 1);
    private tip() {
        /**弹窗容器 */
        const container = this.container;
        this.stage.addChild(container);
        container.graphics.beginFill(0, .5);
        container.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
        container.graphics.endFill();
        container.touchEnabled = true;
        container.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.tipClose, this);
        const tip = Main.createBitmapByName("tip_png");
        container.addChild(tip);
        Main.anchorCenter(tip);
        tip.x = this.stage.stageWidth * .5;
        tip.y = this.stage.stageHeight * .5;


        this.timer.addEventListener(egret.TimerEvent.TIMER, this.tipClose, this);
        this.timer.start();
    }
    private tipClose(evt: egret.TouchEvent) {
        Main.superStopPropagation(evt);
        this.timer.stop();
        this.stage.removeChild(this.container);
    }
}

